#define  _CRT_SECURE_NO_WARNINGS
class Solution {
public:
    int minCost(vector<vector<int>>& costs) {
        vector<vector<int>> tmp(costs.begin(), costs.end());
        int n = costs.size();
        for (int i = 1; i < n; i++)
        {
            tmp[i][0] += min(tmp[i - 1][1], tmp[i - 1][2]);
            tmp[i][1] += min(tmp[i - 1][0], tmp[i - 1][2]);
            tmp[i][2] += min(tmp[i - 1][0], tmp[i - 1][1]);
        }
        return min(tmp[n - 1][0], min(tmp[n - 1][1], tmp[n - 1][2]));
    }
};